package org.lanlab.storode.dal.entity;

/**
 * @author jingchun
 * @since 2020/3/15
 */
public enum CodeSegmentType {
    VARIABLE(1, "variable"),
    FUNCTION(2, "function"),
    CLASS(3, "class"),
    FIELD(4, "field"),
    METHOD(5, "method"),
    PACKAGE(6, "package"),
    UNKNOWN(100, "Unknown type");
    Integer code;
    String description;

    CodeSegmentType(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public static CodeSegmentType getByCode(Integer code) {
        for (CodeSegmentType value : CodeSegmentType.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return UNKNOWN;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
